package com.qiniu.shortvideo.utils;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.util.Log;

/**
 * 七牛短视频帮助类
 * Created by Su on 2017/11/10.
 */
public class PLUtils {

    private static boolean isLog = false;    // 七牛调试Log开关

    /**
     * 调试Log打印
     */
    public static void log(String msg) {
        if (isLog)
            Log.d("shortVideo", msg);
    }

    /**
     * 选择本地视频文件
     */
    public static void chooseVideoFile(Activity activity) {
        Intent intent = new Intent();
        if (Build.VERSION.SDK_INT < 19) {
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.setType("video/*");
        } else {
            intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("video/*");
        }
        activity.startActivityForResult(Intent.createChooser(intent, "选择要导入的视频"), 0);
    }

    /**
     * 选择本地音频文件
     */
    public static void chooseAudioFile(Activity activity) {
        Intent intent = new Intent();
        if (Build.VERSION.SDK_INT < 19) {
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.setType("audio/*");
        } else {
            intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("audio/*");
        }
        activity.startActivityForResult(Intent.createChooser(intent, "请选择音乐文件："), 0);
    }
}
